<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>es6解构赋值</title>
</head>

<body>
  <script>

    let arr = [1, 23, 4];
    // let a = arr[0], b = arr[1], c = arr[2]

    // 对数组元素进行解构赋值，把数组的元素赋值给左边数组里面的变量，变量被赋值后，就可以直接使用变量。
    // let [a, b, c] = arr;
    // console.log(a, b, c); //1 23 4


    // 默认值
    // let [a, b = 1, c, d = 12] = arr;
    // console.log(a, b, c, d); //1 23 4 12


    // 对象的解构赋值：
    var { 'a': a1, 'b': b2, 'c': c3 } = { 'a': 1, 'b': 3, 'c': 4 }
    console.log(a1, b2, c3); //1 3 4

    var { a, b, c } = { 'a': 1, 'b': 3, 'c': 4 }
    console.log(a, b, c);//1 3 4


  </script>
</body>

</html>